from django.http import HttpResponse
from django.template import Context, Template
from django.template.loader import get_template
from django.shortcuts import render_to_response
import datetime

def index(request):
	t = get_template('index.html')
	return render_to_response('index.html', {})
	
def helloworld(request):
	return HttpResponse('Hello World!')
	
def sayhello(request, name):
	# t = Template("Hello {{ name }}!")
	# c = Context({"name": name})
	# return HttpResponse(t.render(c))
	t = get_template('sayhello.html')
	c = Context({"name": name})
	return render_to_response('sayhello.html', {"name": name})
	
def current_datetime(request):
	now = datetime.datetime.now()
	html = "<html><body>It is now %s.</body></html>" % now
	return HttpResponse(html)
	
def hours_ahead(request, offset):
	offset = int(offset)
	dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
	html = "<html><body>In %s hour(s), it will be %s.</body></html>" % (offset, dt)
	return HttpResponse(html)
	
def foobar_view(request, url):
	return HttpResponse('This is %s.' % url)
